package com.yiqi.lottery.feature.documentary.view.adapter;

import android.text.Html;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.suozhang.framework.framework.AM;
import com.yiqi.lottery.R;
import com.yiqi.lottery.entity.bo.LotteryBo;
import com.yiqi.lottery.entity.enums.BangDanType;

public class LotteryListAdapter extends BaseQuickAdapter<LotteryBo, BaseViewHolder> {

    private int type;

    public LotteryListAdapter(int type) {
        super(type == 3 ? R.layout.item_documentary_lottery_lianhonglist : R.layout.item_documentary_lottery_list);
        this.type = type;
    }

    @Override
    protected void convert(BaseViewHolder helper, LotteryBo item) {
        String content = "";
        if (type == BangDanType.LIANHONG.getIndex()) {
            content = "<font color=\"#EA002A\">" + helper.getAdapterPosition() + "</font>连红";
        } else if (type == BangDanType.HONGDAN.getIndex()) {
            content = "投<font color=\"#EA002A\">" + 5 + "</font>";
        }

        helper.setText(R.id.tv_lottery_level, (helper.getAdapterPosition() + 1) + "")
                .setText(R.id.tv_lottery_type, type==3?item.getContinus() + "日连红":"投"+item.getRatio() )
                .setText(R.id.tv_user_name, item.getUser_info() == null ? "" : item.getUser_info().getUsername())
                .setText(R.id.tv_lottery_des, item.getContinus() + "日红单")
        ;

        if (type==3){
            helper.setText(R.id.tv_lottery_leiji,  "累积带红 : "+item.getBand_amount()+"人")
                    .setText(R.id.tv_lottery_count, Html.fromHtml("<font color=\"#EA002A\">" + item.getBand_seven() + "</font>人") );
        }

        AM.image().bindToCircleObject(item.getUser_info() == null ? "" : item.getUser_info().getAvatar(), helper.getView(R.id.iv_lottery_head));


        if (helper.getAdapterPosition() == 0) {
            helper.setBackgroundRes(R.id.tv_lottery_level, R.drawable.documentary_list_first_sign);
        } else if (helper.getAdapterPosition() == 1) {
            helper.setBackgroundRes(R.id.tv_lottery_level, R.drawable.documentary_list_second_sign);
        } else if (helper.getAdapterPosition() == 2) {
            helper.setBackgroundRes(R.id.tv_lottery_level, R.drawable.documentary_list_third_sign);
        }
    }
}
